//
//  ProgessView.swift
//  weibo
//
//  Created by 叶子韬韬 on 2017/5/13.
//  Copyright © 2017年 叶子韬韬. All rights reserved.
//

import UIKit

class ProgessView: UIView {

    
    var progess:CGFloat = 0{
        didSet{
            setNeedsDisplay()
        }
    }
    
    
    override func draw(_ rect: CGRect) {
        
        super.draw(rect)
        
        let center = CGPoint.init(x: rect.width*0.5, y: rect.height*0.5)
        let radius = rect.width*0.5 - 3
        let startAngle = CGFloat(-M_PI_2)
        let endAngle = CGFloat(2*M_PI)*progess + startAngle
        
        //创建贝塞尔曲线
        let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
        
        //绘制一天中心点的线
        
        path.addLine(to: center)
        path.close()
        
        //设置绘制颜色
        UIColor(white: 1.0, alpha: 0.4).setFill()
        //开始绘制
        path.fill()
        
        
    }

}
